﻿#ifndef MCLIENT_H
#define MCLIENT_H

#include <QObject>
#include <QAbstractSocket>
#include <QJsonObject>

class MClientPrivate;
class QAbstractSocket;
class MClient : public QObject
{
    Q_OBJECT
public:
    explicit MClient(const QString &ipAddr,int port,QObject *parent = nullptr);
    ~MClient();
public slots:
    void sendData(const QString &data);
signals:
    void stateChanged(int state);
    void newCommand(const QVariant &jsObj);
    void newRefresh(const QVariant &jsObj);
public slots:
    void startConnect();
    void socketStateChanged(QAbstractSocket::SocketState state);
    void socketReadyRead();
private:
    QJsonObject getRootJsObj(const QByteArray &data);
private: 
    MClientPrivate *d;
};

#endif // MCLIENT_H
